import java.util.Stack;

public class MyQueue {
    private Stack<Integer> s1;
    private Stack<Integer> s2;
    public MyQueue() {
        this.s1 = new Stack<>();
        this.s2 = new Stack<>();
    }

    //统一存入s1
    public void push(int x) {
        s1.push(x);
    }

    //把s1中的元素倒放进s2然后输出s2的栈顶元素
    public int pop() {
        if (empty()){
            return -1;
        }
        int tmp = 0;
        if(s2.empty()) {
            while (!s1.empty()){
                tmp = s1.pop();
                s2.push(tmp);
            }
        }
        return s2.pop();
    }

    public int peek() {
        if (empty()){
            return -1;
        }
        int tmp = 0;
        if(s2.empty()) {
            while (!s1.empty()){
                tmp = s1.pop();
                s2.push(tmp);
            }
        }
        return s2.peek();
    }

    public boolean empty() {
        return s1.empty() && s2.empty();
    }
}
